home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / oop_tp55.zip / LIST4_3.PAS < prev    next >
Pascal/Delphi Source File  |  1990-01-09  |  3KB  |  107 lines

  1. program Listing4-3;
  2.  
  3. uses Tags, Crt, Graph, NewTags, PlotData;
  4.  
  5. var
  6.    LT100,
  7.    FT100  : Analog;
  8.    PSL100 : LoSwitch;
  9.    PSH100 : HiSwitch;
  10.    EY100  : NewPump;
  11.    time   : integer;
  12.    SPress, PFlow, SFlow : Plot;
  13.    GraphDriver, GraphMode : integer;
  14.    Slice : integer;
  15.  
  16. {$F+}
  17. function SystemPressure : real;
  18. begin
  19.      SystemPressure := HtToPSI(LT100.GetValue);
  20. end;
  21. {$F-}
  22.  
  23. procedure SetNewFlowRate( i : integer );
  24. begin
  25.      if i > 1400 then FT100.PutValue(4000)
  26.      else
  27.      if i > 1000 then FT100.PutValue(500)
  28.      else
  29.      if i > 800 then FT100.PutValue(3000)
  30.      else
  31.      if i > 620 then FT100.PutValue(6600)
  32.      else
  33.      if i > 480 then FT100.PutValue(8600)
  34.      else
  35.      if i > 240 then FT100.PutValue(7000)
  36.      else
  37.      if i > 120 then FT100.PutValue(4000)
  38.      else
  39.      if i > 60 then FT100.PutValue(5000);
  40. end;
  41.  
  42. begin
  43.  
  44.      GraphDriver := Detect;
  45.      InitGraph( GraphDriver, GraphMode, '' );
  46.      Graph.SetColor( white );
  47.  
  48.      Slice := GetMaxY div 6;
  49.  
  50.      SPress.Init( 40, 100, 1,
  51.                  0, 1440, 1,
  52.                  50,GetMaxX-50,0,2*Slice-20,
  53.                  0,0,1,2,
  54.                  'SystemPressure vs. Time', 't, min', 'psi',
  55.                  false );
  56.      PFlow.Init( 0, 100, 100,
  57.                  0, 1440, 1,
  58.                  50,GetMaxX-50,2*Slice,4*Slice-20,
  59.                  0,0,1,2,
  60.                  'Pump Discharge Flow vs. Time', 't, min', 'gpm (x100)',
  61.                  false );
  62.      SFlow.Init( 0,100, 100,
  63.                  0,1440, 1,
  64.                  50,GetMaxX-50,4*Slice,6*Slice-20,
  65.                  0,0,1,2,
  66.                  'System Flow vs. Time', 't, min', 'gpm (x100)',
  67.                  false);
  68.  
  69.      SPress.DrawHGridLine( 60 );
  70.      SPress.DrawHGridLine( 75 );
  71.      SPress.PlaceYAxisValue( 60 );
  72.      SPress.PlaceYAxisValue( 75 );
  73.  
  74.      Quiet.On;  { to shut up the Digitals }
  75.      LT100.Init( 'LT100', 2048, 50, 250 );
  76.      FT100.Init( 'FT100', 2048, 0, 10000 );
  77.      PSL100.Init( 'PSL100', 60, SystemPressure );
  78.      PSH100.Init( 'PSH100', 75, SystemPressure );
  79.      EY100.Init( 'EY100', off, 100, 4.8e-7, @SystemPressure);
  80.  
  81.      for time := 0 to 1440 do
  82.     begin
  83.     { adjust level for water leaving tank }
  84.         LT100.PutValue( LT100.GetValue - FlowToDeltaHt(FT100.GetValue) );
  85.     { figure out PSL and PSH readings }
  86.         PSL100.PutReading( SystemPressure );
  87.         PSH100.PutReading( SystemPressure );
  88.  
  89.         if PSL100.GetStatus = on then
  90.            EY100.PutStatus( ON );
  91.         if PSH100.GetStatus = on then
  92.            EY100.PutStatus( OFF );
  93.         LT100.PutValue( LT100.GetValue + FlowToDeltaHt( EY100.Flow ));
  94.  
  95.         SPress.AddPoint( time, SystemPressure );
  96.         PFlow.AddPoint( time, EY100.Flow );
  97.         SFlow.AddPoint( time, FT100.GetValue );
  98.  
  99.         SetNewFlowRate( time );
  100.      end;
  101.  
  102.      repeat until KeyPressed;
  103.      RestoreCRTMode;
  104. end.
  105.  
  106.  
  107.